#!/usr/bin/env bash

set -euo pipefail

# allow the container to be started with `--user`
if [ "$(id -u)" = '0' ]; then
    if [ -d /docker-entrypoint-init.d ]; then
        for script in `find /docker-entrypoint-init.d -name "*.sh" | sort`; do
	    sh $script
        done 
    fi
    find $ATLASSIAN_INSTALL_DIR \! -user atlassian -exec chown atlassian '{}' +
    find $ATLASSIAN_HOME \! -user atlassian -exec chown atlassian '{}' +
    exec gosu atlassian "$BASH_SOURCE" "$@"
fi

exec "$@"

